import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.persistence.Query;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.Version;

import play.*;
import play.db.jpa.GenericModel.JPAQuery;
import play.db.jpa.JPA;
import play.jobs.*;
import play.test.*;
import service.bingosearch.IndexManager;

import models.*;

@OnApplicationStart
public class Bootstrap extends Job {
    
	
	
    public void doJob() throws LockObtainFailedException, IOException {
		if (User.count() == 0) {
		    Fixtures.loadModels("initial-data.yml");
		}
		
		try {
			new IndexManager().BuildSearchIndexes();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
    }


    
}